import struct,codecs,os
from win32com.client import Dispatch
from types import NoneType

xls=Dispatch('Excel.Application')
book=xls.Workbooks.Open(os.getcwd()+os.sep+'strings.xls')
n=book.ActiveSheet

tar=open('strings.strl','r+b')
tar.seek(0x28)
num=struct.unpack('i',tar.read(4))[0]
tar.seek(0x68)
baseoffset=struct.unpack('i',tar.read(4))[0]
tar.seek(baseoffset)
offsetlist=[]
sizelist=[]
for i in xrange(2,1375,1):
    start=tar.tell()
    string=n.Cells(i,3).Value
    if isinstance(string,NoneType):
        string=n.Cells(i,2).Value
    print string
    string=string.replace('\r','')
    tar.write(string.encode('utf16')[2:])
    tar.write('\x00\x00')
    end=tar.tell()
    sizelist.append(end-start)
    offsetlist.append(start-baseoffset)
for j in xrange(num):
    tar.seek(0x90+j*16+4)
    tar.write(struct.pack('i',sizelist[j]))
    tar.write(struct.pack('i',offsetlist[j]))
xls.Quit()